<?php

namespace App\Console\Crons;

use App\Jobs\AdPostbackToMediaQueue;
use App\Models\Log\LogAdPostbackMedia;

class AdPostbackMediaCron extends CronBase
{
    public function run($stime)
    {
        $end_time   = $stime + 86400;
        $query = LogAdPostbackMedia::whereRaw("create_time>={$stime} AND create_time<{$end_time} AND status IN(60)");

        $query->chunk(10000, function ($list) {
            foreach ($list as $log) {
                AdPostbackToMediaQueue::dispatch($log->id)->onQueue('default');
            }
        });
    }
}
